package Visao;


import Controle.ControlProduto;
import java.awt.AWTKeyStroke;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.KeyStroke;
import modelo.Produto;
import modelo.ProdutoLista;
import Controle.Conectabanco;

/**
 *
 * @author Denize
 */
public class TelaCadastroProduto extends javax.swing.JFrame {

    Conectabanco conecta = new Conectabanco();
    Produto prodproduto = new Produto();
    ControlProduto control = new ControlProduto();

    /**
     * Creates new form CadastroProduto
     */
    public TelaCadastroProduto() {
        initComponents();
        conecta.conexao();

        produtoLista = new ProdutoLista();

        Set<AWTKeyStroke> forwardKeys;
        forwardKeys = new HashSet<AWTKeyStroke>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
        forwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
        this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);

    }
    Produto produto;
    ProdutoLista produtoLista;
    List<Produto> produtos;

    {
        //  public TelaCadastroProduto() {
        //initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem3 = new javax.swing.JCheckBoxMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jButton2 = new javax.swing.JButton();
        jcodigodoproduto = new javax.swing.JLabel();
        jCP = new javax.swing.JTextField();
        jdescricaodoproduto = new javax.swing.JLabel();
        jDP = new javax.swing.JTextField();
        jQ = new javax.swing.JTextField();
        jquant = new javax.swing.JLabel();
        jVP = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTabelaproduto = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jVC = new javax.swing.JTextField();
        jVV = new javax.swing.JTextField();
        jnovo = new javax.swing.JButton();
        jsalvar = new javax.swing.JButton();
        jeditar = new javax.swing.JButton();
        jexcluir = new javax.swing.JButton();
        jcancelar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jFornecedor = new javax.swing.JTextField();
        jButtonPesquisar = new javax.swing.JButton();
        jpesquisar = new javax.swing.JTextField();

        jMenuItem1.setText("jMenuItem1");

        jMenu1.setText("jMenu1");

        jMenuItem2.setText("jMenuItem2");

        jMenuItem3.setText("jMenuItem3");

        jMenuItem4.setText("jMenuItem4");

        jMenuItem5.setText("jMenuItem5");

        jMenuItem6.setText("jMenuItem6");

        jCheckBoxMenuItem1.setSelected(true);
        jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");

        jCheckBoxMenuItem2.setSelected(true);
        jCheckBoxMenuItem2.setText("jCheckBoxMenuItem2");

        jCheckBoxMenuItem3.setSelected(true);
        jCheckBoxMenuItem3.setText("jCheckBoxMenuItem3");

        jMenu2.setText("jMenu2");

        jMenu3.setText("jMenu3");

        jMenu4.setText("jMenu4");

        jMenuItem7.setText("jMenuItem7");

        jButton2.setText("jButton2");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cadastro de produtos");
        setBackground(new java.awt.Color(204, 255, 204));

        jcodigodoproduto.setText("Cód:");

        jCP.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jCP.setEnabled(false);
        jCP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCPActionPerformed(evt);
            }
        });

        jdescricaodoproduto.setText("Descrição do Produto:");

        jDP.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jDP.setEnabled(false);

        jQ.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jQ.setEnabled(false);
        jQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jQActionPerformed(evt);
            }
        });

        jquant.setText("Quantidade:");

        jVP.setText("Voltar ao menu Principal");
        jVP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jVPActionPerformed(evt);
            }
        });

        jTabelaproduto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Cód. Produto", "Desc.Produto", "Quant.", "Valor da Compra", "Valor da Venda", "Fornecedor"
            }
        ));
        jScrollPane1.setViewportView(jTabelaproduto);

        jLabel4.setText("Valor de compra:");

        jLabel8.setText("Valor de venda:");

        jVC.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jVC.setEnabled(false);
        jVC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jVCActionPerformed(evt);
            }
        });

        jVV.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jVV.setEnabled(false);
        jVV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jVVActionPerformed(evt);
            }
        });

        jnovo.setText("Novo");
        jnovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jnovoActionPerformed(evt);
            }
        });

        jsalvar.setText("Salvar");
        jsalvar.setEnabled(false);
        jsalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jsalvarActionPerformed(evt);
            }
        });

        jeditar.setText("Editar");
        jeditar.setEnabled(false);
        jeditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jeditarActionPerformed(evt);
            }
        });

        jexcluir.setText("Excluir");
        jexcluir.setEnabled(false);
        jexcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jexcluirActionPerformed(evt);
            }
        });

        jcancelar.setText("Cancelar");
        jcancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcancelarActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 0, 153));
        jLabel1.setText("CADASTRO DE PRODUTOS");

        jLabel2.setText("Fornecedor:");

        jFornecedor.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jFornecedor.setEnabled(false);

        jButtonPesquisar.setText("Pesquisar");
        jButtonPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPesquisarActionPerformed(evt);
            }
        });

        jpesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jpesquisarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(82, 82, 82)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jdescricaodoproduto)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jDP, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jquant)
                    .addComponent(jQ, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jVP))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 572, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCP, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcodigodoproduto, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jVC, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jnovo)
                        .addGap(18, 18, 18)
                        .addComponent(jsalvar)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jVV, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 219, Short.MAX_VALUE))
                                    .addComponent(jFornecedor)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jeditar)
                                .addGap(18, 18, 18)
                                .addComponent(jexcluir)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcancelar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jpesquisar, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(30, 30, 30)
                        .addComponent(jButtonPesquisar))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcodigodoproduto)
                    .addComponent(jdescricaodoproduto)
                    .addComponent(jquant))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jDP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jQ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel4)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jVV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jFornecedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jVC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jnovo)
                    .addComponent(jsalvar)
                    .addComponent(jeditar)
                    .addComponent(jexcluir)
                    .addComponent(jcancelar)
                    .addComponent(jButtonPesquisar)
                    .addComponent(jpesquisar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25)
                .addComponent(jVP)
                .addContainerGap(34, Short.MAX_VALUE))
        );

        setSize(new java.awt.Dimension(681, 419));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jQActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jQActionPerformed

    private void jVPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jVPActionPerformed
        dispose();
        TelaPrincipal.main(null);
        // TODO add your handling code here:
    }//GEN-LAST:event_jVPActionPerformed

    private void jCPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCPActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCPActionPerformed

    private void jVCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jVCActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jVCActionPerformed

    private void jVVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jVVActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jVVActionPerformed

    private void jsalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jsalvarActionPerformed

        prodproduto.setDescproduto(jDP.getText());
        prodproduto.setNomefornecedor(jFornecedor.getText());
        prodproduto.setValcompra(Float.parseFloat(jVC.getText()));
        prodproduto.setValvenda(Float.parseFloat(jVV.getText()));
        prodproduto.setQtdproduto(Integer.parseInt(jQ.getText()));
        control.inserirproduto(prodproduto);
        jDP.setEnabled(!true);
        jCP.setEditable(!true);
        jQ.setEnabled(!true);
        jFornecedor.setEnabled(!true);
        jVC.setEnabled(!true);
        jVV.setEnabled(!true);
        jCP.setText("");
        jpesquisar.setText("");
        jDP.setText("");
        jQ.setText("");
        jFornecedor.setText("");
        jVC.setText("");
        jVV.setText("");
        jsalvar.setEnabled(!true);
        jeditar.setEnabled(!true);
        jexcluir.setEnabled(!true);
        jnovo.setEnabled(!false);
        jcancelar.setEnabled(!true);


    }//GEN-LAST:event_jsalvarActionPerformed

    private void jnovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jnovoActionPerformed
        jDP.setEnabled(true);
        jCP.setEditable(true);
        jQ.setEnabled(true);
        jFornecedor.setEnabled(true);
        jVC.setEnabled(true);
        jVV.setEnabled(true);
        jCP.setText("");
        jpesquisar.setText("");
        jDP.setText("");
        jQ.setText("");
        jFornecedor.setText("");
        jVC.setText("");
        jVV.setText("");
        jsalvar.setEnabled(true);

        jnovo.setEnabled(false);
        jcancelar.setEnabled(true);



        // TODO add your handling code here:
    }//GEN-LAST:event_jnovoActionPerformed

    private void jeditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jeditarActionPerformed
        prodproduto.setIdproduto(Integer.parseInt(jCP.getText()));
        prodproduto.setDescproduto(jDP.getText());
        prodproduto.setNomefornecedor(jFornecedor.getText());
        prodproduto.setValcompra(Float.parseFloat(jVC.getText()));
        prodproduto.setValvenda(Float.parseFloat(jVV.getText()));
        prodproduto.setQtdproduto(Integer.parseInt(jQ.getText()));
        control.editaProduto(prodproduto);
        jDP.setEnabled(!true);
        jCP.setEditable(!true);
        jQ.setEnabled(!true);
        jFornecedor.setEnabled(!true);
        jVC.setEnabled(!true);
        jVV.setEnabled(!true);
        jCP.setText("");
        jpesquisar.setText("");
        jDP.setText("");
        jQ.setText("");
        jFornecedor.setText("");
        jVC.setText("");
        jVV.setText("");
        jsalvar.setEnabled(!true);
        jeditar.setEnabled(!true);
        jexcluir.setEnabled(!true);
        jnovo.setEnabled(!false);
        jcancelar.setEnabled(!true);


        // TODO add your handling code here:
    }//GEN-LAST:event_jeditarActionPerformed

    private void jexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jexcluirActionPerformed

        prodproduto.setIdproduto(Integer.parseInt(jCP.getText()));
        control.ExcluirProduto(prodproduto);
        jDP.setEnabled(!true);
        jCP.setEditable(!true);
        jQ.setEnabled(!true);
        jFornecedor.setEnabled(!true);
        jVC.setEnabled(!true);
        jVV.setEnabled(!true);
        jCP.setText("");
        jpesquisar.setText("");
        jDP.setText("");
        jQ.setText("");
        jFornecedor.setText("");
        jVC.setText("");
        jVV.setText("");
        jsalvar.setEnabled(!true);
        jeditar.setEnabled(!true);
        jexcluir.setEnabled(!true);
        jnovo.setEnabled(!false);
        jcancelar.setEnabled(!true);

        // TODO add your handling code here:
    }//GEN-LAST:event_jexcluirActionPerformed

    private void jcancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcancelarActionPerformed
        jDP.setEnabled(!true);
        jCP.setEditable(!true);
        jQ.setEnabled(!true);
        jFornecedor.setEnabled(!true);
        jVC.setEnabled(!true);
        jVV.setEnabled(!true);
        jCP.setText("");
        jpesquisar.setText("");
        jDP.setText("");
        jQ.setText("");
        jFornecedor.setText("");
        jVC.setText("");
        jVV.setText("");
        jsalvar.setEnabled(!true);
        jeditar.setEnabled(!true);
        jexcluir.setEnabled(!true);
        jnovo.setEnabled(!false);
        jcancelar.setEnabled(!true);


        // TODO add your handling code here:
    }//GEN-LAST:event_jcancelarActionPerformed

    private void jButtonPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPesquisarActionPerformed
        prodproduto.setPesqproduto(jpesquisar.getText());//  chama o negócio produto
        Produto prodp;// instancia
        prodp = control.buscaProduto(prodproduto);
        jCP.setText(String.valueOf(prodp.getIdproduto()));
        jDP.setText(prodp.getDescproduto());
        jFornecedor.setText(prodp.getNomefornecedor());
        jQ.setText(String.valueOf(prodp.getQtdproduto()));
        jVC.setText(String.valueOf(prodp.getValcompra()));
        jVV.setText(String.valueOf(prodp.getValvenda()));
        jeditar.setEnabled(true);
        jexcluir.setEnabled(true);
        jDP.setEnabled(true);
        jCP.setEditable(true);
        jQ.setEnabled(true);
        jFornecedor.setEnabled(true);
        jVC.setEnabled(true);
        jVV.setEnabled(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonPesquisarActionPerformed

    private void jpesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jpesquisarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jpesquisarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaCadastroProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaCadastroProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaCadastroProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaCadastroProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new TelaCadastroProduto().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonPesquisar;
    private javax.swing.JTextField jCP;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem3;
    private javax.swing.JTextField jDP;
    private javax.swing.JTextField jFornecedor;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JTextField jQ;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTabelaproduto;
    private javax.swing.JTextField jVC;
    private javax.swing.JButton jVP;
    private javax.swing.JTextField jVV;
    private javax.swing.JButton jcancelar;
    private javax.swing.JLabel jcodigodoproduto;
    private javax.swing.JLabel jdescricaodoproduto;
    private javax.swing.JButton jeditar;
    private javax.swing.JButton jexcluir;
    private javax.swing.JButton jnovo;
    private javax.swing.JTextField jpesquisar;
    private javax.swing.JLabel jquant;
    private javax.swing.JButton jsalvar;
    // End of variables declaration//GEN-END:variables
}
